//开始界面按钮的定义
function startGame() {
  var element = document.getElementById("open1");
  element.classList.add("fade-out");
  setTimeout(function() {
    window.location.href = "others/gameopen.html";
  }, 500); 
}
function starthelp() {
  var element = document.getElementById("open2");
  element.classList.add("fade-out");
  setTimeout(function() {
    window.location.href = "gameopen.html";
  }, 500); 
}
/*背景音乐的播放*/
/*背景音乐的播放*/
var audio = document.getElementById("myAudio");
var button = document.getElementById("mc");

function toggleMusic() {
  if (audio.paused) {
    audio.play();
    button.style.backgroundImage = "url('../images/music1.png')";
  } else {
    audio.pause();
    button.style.backgroundImage = "url('../images/music0.png')";
  }
}
function toggleMusic() {
  if (audio.paused) {
    audio.play();
    button.style.backgroundImage = "url('../images/music1.png')";
  } else {
    audio.pause();
    button.style.backgroundImage = "url('../images/music0.png')";
  }
}

/*点击屏幕的音效*/
  var clickSound = new Audio('../music/click.mp3');

    function playClickSound() {
      clickSound.play();
    }

    document.addEventListener('click', function() {
      playClickSound();
    });
    //获取按钮元素
    var helpButton = document.getElementById('help');
    var whereButton = document.getElementById('where');
    var bagButton = document.getElementById('bag');
    var petButton = document.getElementById('pet');
    
    // 获取弹窗元素
    var helpPopup = document.getElementById('helpPopup');
    var wherePopup = document.getElementById('wherePopup');
    var bagPopup = document.getElementById('bagPopup');
    var petPopup = document.getElementById('petPopup');
    
    // 获取关闭按钮元素
    var closeButtons = document.getElementsByClassName('close-popup');
    
    // 点击按钮显示对应的弹窗
    helpButton.addEventListener('click', function() {
      helpPopup.style.display = 'block';
    });
    
    whereButton.addEventListener('click', function() {
      wherePopup.style.display = 'block';
    });
    
    bagButton.addEventListener('click', function() {
      bagPopup.style.display = 'block';
    });
    
    petButton.addEventListener('click', function() {
      petPopup.style.display = 'block';
    });
    
    // 点击关闭按钮关闭弹窗
    for (var i = 0; i < closeButtons.length; i++) {
      closeButtons[i].addEventListener('click', function() {
        var popup = this.closest('.popupa');
        if (popup) {
          popup.style.display = 'none';
        }
      });
    }
    